package com.motu.monstercity.server.game.logic;

import com.motu.monstercity.server.game.userdata.*;
import com.motu.vertx.module.utility.model.EntityManager;
import com.motu.vertx.module.utility.model.Model;

import java.util.ArrayList;
import java.util.List;

public class ChildUserData extends ChildBaseData{
    public static UserChildInfo getUserChildInfo(long userId){
        return (UserChildInfo) EntityManager.getUniqueEntity(UserChildInfo.class, userId);
    }


    /**
     * 获取用户所有未婚子嗣数据
     * @param userId
     * @return
     */
    public static List<UserChildUnmarried> getUserChildUnmarriedList(long userId){
        List<UserChildUnmarried> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserChildUnmarried.class, userId)) {
            UserChildUnmarried entity = (UserChildUnmarried) model;
            list.add(entity);
        }
        return list;
    }

    /**
     * 获取用户所有未婚子嗣数据
     * @param userId
     * @return
     */
    public static UserChildUnmarried getUserChildUnmarried(long userId, long id){
        return (UserChildUnmarried) EntityManager.getEntity(UserChildUnmarried.class, userId, id);
    }

    // 根据dbid 获取UserChildAlone
    public static UserChildAlone getUserChildAlone(long userId, long dbid) {
        return (UserChildAlone) EntityManager.getEntity(UserChildAlone.class, userId, dbid);
    }

    public static UserMarryRobot getUserMarryRobot(long childId, long dbid) {
        return (UserMarryRobot) EntityManager.getEntity(UserMarryRobot.class, childId, dbid);
    }

    public static UserMarryApply getUserMarryApply(long userId, long childId) {
        return (UserMarryApply) EntityManager.getEntity(UserMarryApply.class, userId, childId);
    }

    public static List<UserMarryApply> getUserMarryApplyList(long userId){
        List<UserMarryApply> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserMarryApply.class, userId)) {
            UserMarryApply entity = (UserMarryApply) model;
            list.add(entity);
        }
        return list;
    }

    public static List<UserMarryRobot> getUserMarryRobotList(long childId){
        List<UserMarryRobot> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserMarryRobot.class, childId)) {
            UserMarryRobot entity = (UserMarryRobot) model;
            list.add(entity);
        }
        return list;
    }

    /**
     * 获取用户所有不婚主义子嗣数据
     * @param userId
     * @return
     */
    public static List<UserChildAlone> getUserChildAloneList(long userId){
        List<UserChildAlone> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserChildAlone.class, userId)) {
            UserChildAlone entity = (UserChildAlone) model;
            list.add(entity);
        }
        return list;
    }

    public static UserChildMarry getUserChildMarry(long userId, long dbid) {
        return (UserChildMarry) EntityManager.getEntity(UserChildMarry.class, userId, dbid);
    }


    public static List<UserChildMarry> getUserChildMarryList(long userId){
        List<UserChildMarry> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserChildMarry.class, userId)) {
            UserChildMarry entity = (UserChildMarry) model;
            list.add(entity);
        }
        return list;
    }

    public static ServerMarryInfo getServerMarryInfo(int serverId, long dbid) {
        return (ServerMarryInfo) EntityManager.getEntity(ServerMarryInfo.class, serverId, dbid);
    }

    public static List<ServerMarryInfo> getServerMarryInfoList(int serverId){
        List<ServerMarryInfo> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(ServerMarryInfo.class, serverId)) {
            ServerMarryInfo entity = (ServerMarryInfo) model;
            list.add(entity);
        }
        return list;
    }



    /**
     * 获取教室数据
     * @param userId
     * @param id
     * @return
     */
    public static UserChildCls getUserChildCls(long userId, long id){
        return (UserChildCls) EntityManager.getEntity(UserChildCls.class, userId, id);
    }

    /**
     * 获取教室数据列表
     * @param userId
     * @return
     */
    public static List<UserChildCls> getUserChildClsList(long userId){
        List<UserChildCls> list = new ArrayList<>();
        for (Model model : EntityManager.getEntityList(UserChildCls.class, userId)) {
            UserChildCls entity = (UserChildCls) model;
            list.add(entity);
        }
        return list;
    }
}
